import Cookies from './Cookies'
const https="https://shop.satecn.com:8085";
//const https="http://192.168.3.123:8085";
//const https="http://127.0.0.1:8085";
export default {
    get(url,data) {		
        return this.request(url,"GET",data)
    },	
	posts(url, data) {
		return new Promise((resolve,reject)=>{
			uni.request({
			    url: https+url,
				method:'POST',
			    data:data,
				timeout:80000,
			    header: {
					'Authorization': Cookies.getUserToken(),
					'content-type':'application/x-www-form-urlencoded'
			    },
			    success: (res) => {
					resolve(res)
			    },fail:(err)=>{
					
					reject(err)
				}
			});
		}) 
	},
	
	post(url,data) {
	    return this.request(url,"POST",data)
	},
	request(url,method,data) {
	    return new Promise((resolve,reject)=>{
			uni.request({
			    url: https+url,
				method:method,
			    data:data,
				timeout:80000,
			    header: {
					'Authorization': Cookies.getUserToken() ,
			    },
			    success: (res) => {
					resolve(res)
			    },fail:(err)=>{
					reject(err)	
				}
			});
		}) 
	},
    // get(url, data) {
    //     return axios.get(url, { headers: { 'Authorization': tokenStr }, params: data })
    // },
 
    // post(url, data) {
    //     return axios.post(url, data, { headers: { 'Authorization': tokenStr } })
    // },
    policy(){
		return new Promise((resolve,reject)=>{
			uni.request({
			    url: https+'/aliyun/oss/policy',
				method:'get',
			    header: {
					'Authorization': Cookies.getUserToken() ,
					'content-type':'application/x-www-form-urlencoded'
			    },
			    success: (res) => {
					resolve(res)
			    },fail:(err)=>{
					reject(err)
				}
			});
		}) 
	},
	accessToken(){
		return new Promise((resolve,reject)=>{
			uni.request({
			    url: https+'/wx/accessToken',
				method:'get',
			    
			    success: (res) => {
					resolve(res)
			    },fail:(err)=>{
					reject(err)
				}
			});
		}) 
	},
    // form(url, data) {
    //     return axios.post(url, data, { headers: { 'Authorization': tokenStr ,'Content-Type':'application/x-www-form-urlencoded'} })
    // },
   
}